package com.itheima.edu.info.manager.service;

import com.itheima.edu.info.manager.dao.StudentDao;
import com.itheima.edu.info.manager.domain.Student;

import java.util.ArrayList;

public class StudentService {
    StudentDao studentDao = new StudentDao();
    ArrayList<Student> list = studentDao.findAllStudent();
    public boolean addStudent(Student stu) {

        ArrayList<Student> list = studentDao.findAllStudent();

            return studentDao.addStudent(stu);

    }
    public boolean isExists(String id){

        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            if (id.equals(student.getId())){
                return true;
            }
        }
        return false;
    }

    public ArrayList<Student> findAllStudent() {
        return studentDao.findAllStudent();
    }

    public void delStudent(String sid) {
        int index = getIndex(sid);
    }

    public int getIndex(String sid) {
        int index = -1;
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
        }
    }
}
